#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#define REP(i,n) for(int i=0;i<int(n);++i)

using namespace std;

string map[5050];

struct Node
{
	char c;
	int ans;
	Node *up,*down,*left,*right;
};

vector<Node> node[5050];
int n,m;


void buildLink()
{
	REP(i,n)
	{
		Node *nt = NULL;
		REP(j,m) if(map[i][j]!='.')
		{
			if(nt)	nt->right = &node[i][j];
			node[i][j].left = nt;
			nt = &node[i][j];
			nt->right = NULL;
		}
	}
	REP(j,m)
	{
		Node *nt = NULL;
		REP(i,n) if(map[i][j]!='.')
		{
			if(nt)	nt->down = &node[i][j];
			node[i][j].up = nt;
			nt = &node[i][j];
			nt->down = NULL;
		}
	}
}

int dfs(Node *nt,int dep)
{
	//printf("%c dep= %d\n",nt->c,dep);
	if(dep>n*m) return dep;
	if(nt->c=='U')
	{
		if(nt->up)
		{
			nt->up->down = nt->down;
			if(nt->down) nt->down->up = nt->up;
			if(nt->left) nt->left->right = nt->right;
			if(nt->right) nt->right->left = nt->left;
			return dfs(nt->up,dep+1);
		}
		return dep;
	}
	else if(nt->c=='D')
	{
		if(nt->down)
		{
			//printf("down %c\n",nt->down->c);
			nt->down->up = nt->up;
			if(nt->up) nt->up->down = nt->down;
			if(nt->left) nt->left->right = nt->right;
			if(nt->right) nt->right->left = nt->left;
			return dfs(nt->down,dep+1);
		}
		return dep;
	}
	else if(nt->c=='L')
	{
		if(nt->left)
		{
			nt->left->right = nt->right;
			if(nt->up) nt->up->down = nt->down;
			if(nt->down) nt->down->up = nt->up;
			if(nt->right) nt->right->left = nt->left;
			return dfs(nt->left,dep+1);
		}
		return dep;
	}
	else
	{
		if(nt->right)
		{
			nt->right->left = nt->left;
			if(nt->up) nt->up->down = nt->down;
			if(nt->down) nt->down->up = nt->up;
			if(nt->left) nt->left->right = nt->right;
			return dfs(nt->right,dep+1);
		}
		return dep;
	}
}
int main()
{
	while(cin>>n>>m)
	{
		REP(i,n) cin>>map[i];
		REP(i,n) REP(j,m)
		{
			node[i].push_back(*new Node);
			node[i][j].c = map[i][j];
		}
		int tmax = -1;
		REP(i,n) REP(j,m) if(map[i][j]!='.')
		{
			//printf("start map[%d][%d] = %c\n",i,j,map[i][j]);
			buildLink();
			node[i][j].ans = dfs(&node[i][j],1);
			tmax = max(tmax,node[i][j].ans);
		}
		int cnt = 0;
		REP(i,n) REP(j,m) if(map[i][j]!='.'&&node[i][j].ans==tmax) cnt++;
		cout<<tmax<<" "<<cnt<<endl;
	}
	return 0;
}
